const webpack = require('webpack');
var utils = require('./utils');
//var styleconfig = require('./styleconfig');
var path = require('path');
var extractTextPlugin = require('extract-text-webpack-plugin');
var autoprefixer = require('autoprefixer');
var px2rem = require('postcss-px2rem');
var precss = require('precss');

module.exports = {
	entry: utils.getEntries(),
	output: {
		path: path.join(__dirname, '../dist'),
		filename: 'js/[name].js',
		publicPath: '/'
	},
    resolve: {
        // require时省略的扩展名，如：require('module') 不需要module.js
        extensions: ['', '.js', '.css', '.vue', '.less'],
        // 别名，可以直接使用别名来代表设定的路径以及其他
        alias: {
            // filter: path.join(__dirname, '../src/resource/filters'),
            // components: path.join(__dirname, '../src/resource/components')
        }
    },
	module: {
		loaders: [
			{ test: /\.vue$/,loader: 'vue' },
			{ test: /\.js$/,exclude: /node_modules/,loader: 'babel-loader' },
			//{ test:/\.css$/,loader:'style!css!postcss' },
            { test: /\.less$/, loader: 'style!css!less'},
			{ test: /\.css$/, loader: extractTextPlugin.extract("style-loader", "css-loader") },
            { test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=8192'}
            //{ test: /\.(html|tpl)$/, loader: 'html-loader' }
		]
	},
    // // 转es5
    // babel: {
    //     presets: ['es2015'],
    //     plugins: ['transform-runtime']
    // },
	// vue : {
	//     loaders: {
	//         css: extractTextPlugin.extract(
	//             "style-loader",
	//             "css-loader?sourceMap",
	//             {
	//                 publicPath: "/dist"
	//             }
	//         ),
	//         less: extractTextPlugin.extract(
	//             'vue-style-loader',
	//             'css-loader!less-loader'
	//         )
	//     }
	// },
	// vue: {
	// 	loaders: styleconfig.cssLoaders()
	// },
	postcss: function() {
		return [precss, autoprefixer({ browsers: ['last 2 versions']}), px2rem({remUnit: 75})]
	}
 };